package com.example.mifi;


import android.app.Activity;
import android.content.Context;
import android.content.IntentFilter;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CheckBox;

public class MainActivity extends Activity 
{
	WifiManager m_wifi;
	WifiReceiver m_receiver;
	
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);
//      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
//                                WindowManager.LayoutParams.FLAG_FULLSCREEN);
//        
        setContentView(R.layout.activity_main);
        
        m_wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        m_receiver = new WifiReceiver(m_wifi, (MapView)findViewById(R.id.view_main));  
        
    	IntentFilter i = new IntentFilter();
        i.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
        registerReceiver(m_receiver, i);
        m_wifi.startScan();
    }

    @Override
    protected void onDestroy()
    {
    	super.onDestroy();
    	unregisterReceiver(m_receiver);
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
        return true;
    }
    
    
    public void onCheckboxClicked(View view) 
    {
        boolean checked = ((CheckBox) view).isChecked();
        switch(view.getId()) 
        {
        	case R.id.checkbox_show:
        		int val = checked ? View.VISIBLE : View.GONE;
        		
        		findViewById(R.id.checkbox_wifi).setVisibility(val);
        		findViewById(R.id.checkbox_accel).setVisibility(val);
        		findViewById(R.id.checkbox_sat).setVisibility(val);
        		findViewById(R.id.checkbox_showrad).setVisibility(val);
            	
    			break;
        	case R.id.checkbox_showrad:
        		((MapView)findViewById(R.id.view_main)).setShowRadius(checked);
                break;
        	case R.id.checkbox_accel:
            	if (checked)
                	;
                else
                	;
                break;
        	case R.id.checkbox_wifi:
        		if (checked)
                	;
                else
                	;
                break;
            case R.id.checkbox_sat:
            	if (checked)
                	;
                else
                	;
                break;
        }
    }
    
    public void button_zoomIn(View view) 
	{
		((MapView)findViewById(R.id.view_main)).zoomIn();
	}
	
	public void button_zoomOut(View view) 
	{
		((MapView)findViewById(R.id.view_main)).zoomOut();
	}
}
